package cn.ljuns.logcollector;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import cn.ljuns.logcollector.util.LogCollector;

public class TestActivity extends Activity {
    Handler handler = new Handler(){
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);

            handler.sendEmptyMessageDelayed(0, 1000);
            Log.e("msg", "test");
        }
    };
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        findViewById(R.id.test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (LogCollector.getInstance(getApplication()).isCollecting()) {
                    LogCollector.getInstance(getApplication()).stop();
                    handler.removeMessages(0);
                } else {
                    handler.removeMessages(0);
                    handler.sendEmptyMessageDelayed(0, 1000);
                    LogCollector.getInstance(getApplication())
                            .setCleanCache(true)
    //                .setTag("EGL_emulation")
    //                .setLevel(LevelUtils.D)
    //                .setTagWithLevel("EGL_emulation", LevelUtils.D)
    //                .setString("onCreate", false)
    //                .setType(TypeUtils.WARN)
//                            .setLevel(LevelUtils.D)
                            .start();
                }

            }
        });
    }
}
